function [] = ZP_rh(indir0,outdir0,period_list)
% ZP_rh.m 9/7/2011 Parker MacCready
%
% create relative humidity (%)

disp('--- ZP_rh ---')

g_list = {'d2';'d3'};

for pp = 1:length(period_list)
    period = period_list{pp};
    disp(['period = ',period])
    for gg = 1:length(g_list)
        g_tag = g_list{gg};
        indir = [indir0,period,'/'];
        outdir = [outdir0,period,'/'];
        if ~(exist(outdir,'dir')==7); mkdir(outdir); end;
        
        psfc = load([indir,'psfc_',g_tag,'.mat']);
        t2 = load([indir,'t2_',g_tag,'.mat']);
        q2 = load([indir,'q2_',g_tag,'.mat']);
        outmat = Z_wmo_RH(psfc.outmat/100,t2.outmat - 273.15,q2.outmat);
        lon = psfc.lon; lat = psfc.lat; tdvec = psfc.tdvec;
        ts1_vec = psfc.ts1_vec; ts2_vec = psfc.ts2_vec;
        varlo = 'qair';
        save([outdir,varlo,'_',g_tag,'.mat'],'lon','lat','tdvec', ...
            'ts1_vec','ts2_vec','outmat');
        clear psfc t2 q2 outmat lon lat tdvec ts1_vec ts2_vec
    end % end of gg loop
end
